package com.wuhan.retrosnaker.sevice.ServiceImpl;

import com.wuhan.retrosnaker.mapper.UserMapper;
import com.wuhan.retrosnaker.sevice.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @author wuhan
 * @date 2019/11/18 16:44
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired(required = false)
    UserMapper userMapper;
    @Override
    public List<Map<String, String>> loginValid(Map<String, String> userInfo) {
        return userMapper.loginValid(userInfo);
    }

    @Override
    public boolean submitScore(Map<String, String> submitInfo) {
        return userMapper.submitScore(submitInfo);
    }

    @Override
    public boolean insertScore(Map<String, String> submitInfo) {
        return userMapper.insertScore(submitInfo);
    }

    @Override
    public int isCreated(Map<String, String> submitInfo) {
        return userMapper.isCreated(submitInfo);
    }

    @Override
    public boolean signUp(Map<String, String> submitInfo) {
        return userMapper.signUp(submitInfo);
    }

    @Override
    public List<Map<String, String>> getRankList() {
        List<Map<String, String>> rankList = userMapper.getRankList();
        rankList.sort(Comparator.comparing(o -> o.get("score")));
        return userMapper.getRankList();
    }
}
